package com.qf.simpleTriggerTest;

import com.qf.util.SpringBean;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

/**
 * 2019/12/6
 * Administrator
 * springboot1206
 * 面向对象面向君  不负代码不负卿
 */
//生产调度器对象
@Configuration
public class Factory {
    @Autowired
    private SpringBean springBean;


    @Bean  //方法名=对象名
    public SchedulerFactoryBean factoryBean(){
        SchedulerFactoryBean factoryBean = new SchedulerFactoryBean();
        factoryBean.setJobFactory(springBean);//新增代码
        return  factoryBean;
    }

    //通过工厂得到调度器
    @Bean
    public Scheduler  getsch(@Qualifier("factoryBean") SchedulerFactoryBean factoryBean){
        return factoryBean.getObject();
    }

}
